// Below functions use prototype javascript library
	function processPlayerInputProt(){
		var userInput = $('enteredLetter').getValue();
		var wordInPlay = $('updatedWord').getValue();
		
		if(userInput == ''){
			alert('Please enter letter');
			return false;
		}
		
		new Ajax.Request('play/fetch.htm',
				  {
				    method:'get',
				    parameters: {wordInPlay : wordInPlay, enteredLetter : userInput},
				    onSuccess: function(transport){
				      var jsonResponse = transport.responseText.evalJSON();
				      //alert("Success! \n\n" + response.evalJSON().wordInPlay);
				      $('enteredLetter').value = "";
				      $('updatedWord').value = jsonResponse.wordInPlay;
						$('userHelperLabel').update("<font color=\"green\"> Pick your next letter: </font>");
									
									
						if(jsonResponse.gameOver){
							$('statusMessage').update(jsonResponse.gameStatus);
							$('enteredLetter').disable();
						}else{
							$('enteredLetter').focus();
						}
				      
				    },
				    onFailure: function(){ alert('Something went wrong...'); }
				  });
	}

	Event.observe(window, 'load', function() {
			$('enteredLetter').focus();
			$('enteredLetter').observe('keypress', function(event){
			    if ( event.keyCode == Event.KEY_RETURN  || event.which == Event.KEY_RETURN ) {
			    	processPlayerInputProt();
			        Event.stop(event);
			    }
			});
	});
	
	/*  Below functions can be used if using JQUERY library
	
	function processPlayerInput() {
		$userInput = document.getElementById('enteredLetter').value;
		$wordInPlay = document.getElementById('updatedWord').value;
		
		if($userInput == ''){
			alert('Please enter letter');
			return false;
		}

		$.get("/play/fetch.htm", {
			"wordInPlay" : $wordInPlay,
			"enteredLetter" : $userInput
		}, function(data) {
			
			document.getElementById('enteredLetter').value = "";
			document.getElementById('updatedWord').value = data.wordInPlay;
			$("#userHelperLabel").html("<font color=\"green\"> Pick your next letter: </font>");
						
						
			if(data.gameOver){
				$("#statusMessage").html(data.gameStatus);
				$("#enteredLetter").attr("disabled", "disabled"); 
			}else{
				$("#enteredLetter").focus();
			}
			
		});
	}
	
	$(document).keypress(function(e) {
    if(e.keyCode == 13) {
        processPlayerInput();
    }
	});
	
    $(document).ready(function() {
    	$("#enteredLetter").focus();
    });
	*/